#pragma once
#include "Game/Process/RenderProcess.h"
#include "Render/Tradition/ComputePipeline.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "../LocalEntity.h"
#include "../LocalShader.h"
#include "../ResourceProcess.h"
#include "../LocalScene.h"

class ShadowsTemporalAccumulationProcess : public RenderProcess
{
	DECLARE_PROCESS(ShadowsTemporalAccumulationProcess)

	struct PushConstants
	{
		float alpha;
		float momentsAlpha;
	};

public:

	PushConstants mPushConstants;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:

	LocalScene* mLocalScene;

	ResourceProcess* mResourceProcess;



	uint32 mOutputWidth;

	uint32 mOutputHeight;



	RefCountPtr<RHITexture> mOutputImage;

	RefCountPtr<RHITexture> mHistoryOutputImage;

	std::array<RefCountPtr<RHITexture>, 2> mMomentsImage;



	RefCountPtr<RHIBuffer> mDenoiseTileCoords;

	RefCountPtr<RHIBuffer> mShadowTileCoords;

	RefCountPtr<RHIBuffer> mDenoiseDispatchArgs;

	RefCountPtr<RHIBuffer> mShadowDispatchArgs;



	RefCountPtr<RHIDescriptor> mDescriptor;

	std::array<DescriptorMask, 2> mCurrentDescriptorMask;

	std::array<DescriptorMask, 2> mHistoryDescriptorMask;

	std::array<DescriptorMask, 2> mGBufferDescriptorMask;

	DescriptorMask mCommonDescriptorMask;


	RefCountPtr<ComputePipeline> mPipeline;

	RefCountPtr<RHICommandBuffer> mCommandBuffer;

	RefCountPtr<RHISemaphore> mWaitGraphicsSemaphore;

	RefCountPtr<RHISemaphore> mSignalComputeSemaphore;

};
